#coding=utf-8
from django import forms  
from django.contrib.auth.models import User    

# 创建网站表单
class WebsiteCreationForm(forms.Form):
    start_url = forms.CharField(  
            required=True,  
            label=u"起始URL",  
            error_messages={'required': u'请输入网站链接'},  
            widget=forms.TextInput(  
                attrs={  
                    'placeholder':u"网站",  
                }  
            ),  
    )    

    allowed_domain = forms.CharField(  
            required=True,  
            label=u"限定域名",  
            error_messages={'required': u'请输入域名'},  
            widget=forms.TextInput(  
                attrs={  
                    'placeholder': u"域名",
                }  
            ),  
    )
    
    def clean(self):  
        if not self.is_valid():  
            raise forms.ValidationError(u"请重新确认填写是否有误")  
        else:  
            cleaned_data = super(WebsiteCreationForm, self).clean()

class KeywordCreationForm(forms.Form):
    keywords = forms.CharField(  
            required=True,  
            label=u"关键词",  
            error_messages={'required': u'请输入关键词'},  
            widget=forms.TextInput(  
                attrs={  
                    'placeholder': u"关键词",
                }  
            )
    )

    def clean(self):  
        if not self.is_valid():  
            raise forms.ValidationError(u"请重新确认填写是否有误")  
        else:  
            cleaned_data = super(KeywordCreationForm, self).clean()

FAVORITE_CLASSES_CHOICES = (
    ('汽车', '汽车'),
    ('财经', '财经'),
    ('科技', '科技'),
    ('健康', '健康'),
    ('体育', '体育'),
    ('旅游', '旅游'),
    ('文化', '文化'),
    ('娱乐', '娱乐'),
    ('时尚', '时尚'),
    ('军事', '军事'),
    ('学习', '学习'),
    ('育儿', '育儿'),
    ('房产', '房产'),
    ('社会', '社会'),
    ('游戏', '游戏'),
    ('政务', '政务'),
)


class ClassesCreationForm(forms.Form):
    classes = forms.ChoiceField(
        label=u"类别",
        choices=FAVORITE_CLASSES_CHOICES,
    )

    def clean(self):
        if not self.is_valid():
            raise forms.ValidationError(u"请重新确认填写是否有误")
        else:
            cleaned_data = super(ClassesCreationForm, self).clean()
